1. Field
The following description relates to a debugging apparatus and method for stopping a program currently being executed and debugging the program.
2. Description of the Related Art
A breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. In order to debug a program, the program must be stopped even in the middle of being executed. The suspension of a program currently being executed may be performed by setting a breakpoint in a particular part of the program code. The setting of a breakpoint may be performed using either a hardware-based method or a software-based method.
The hardware-based method is characterized by providing a limited number of registers in a system at the time of the design of the system and inserting an instruction address, which is the address of an instruction where the execution of a program is stopped, in the registers, so that the program can stop when then the registers and a program counter hit the same value. As an example, the x86 instruction set architecture provides hardware support for breakpoints with its x86 debug registers. However, since the number of registers installed in the system is limited, there is a limit in setting multiple breakpoints using the hardware-based method.
The software-based method is characterized by inserting, during the execution of a program, an instruction that stops the program into the program to set a breakpoint. The program is stopped when encountering the instruction, and the system is switched to a debugging mode. However, when the system is switched back to a normal mode, a face breakpoint may be set in the system, and thus, the performance of the system may deteriorate due to memory read/write operations. That is, in order to resume the program, an operation originally at the address of the instruction needs to be restored, and the setting of the breakpoint needs to be maintained. Thus, a fake breakpoint is set in the next instruction. Thereafter, when the system is switched back to the debugging mode at the fake breakpoint, the original breakpoint is reset, and the fake breakpoint is deleted. As a result, debugging is performed twice. Also, implementing data breakpoints in software can greatly reduce the performance of the Application being debugged, as it is using additional resources on the same physical processor.